<template>
    <div>
        <h1>修改</h1>
        <table>
            <tbody>
                <tr>
                    <td>编号</td>
                    <td>{{ data.Id }}</td>
                </tr>
                <tr>
                    <td>房间名称</td>
                    <td><input type="text" v-model="data.Name"></td>
                </tr>
                <tr>
                    <td>门市价格</td>
                    <td><input type="text" v-model="data.Maney"></td>
                </tr>
                <tr>
                    <td>房间号</td>
                    <td>
                        <input type="checkbox" v-model="data.RoomNum">101
                        <input type="checkbox" >102
                        <input type="checkbox" >103
                        <input type="checkbox" >104
                        <input type="checkbox" >105
                        <input type="checkbox" >106
                        <input type="checkbox" >107
                        <input type="checkbox" >108
                        
                        
                    </td>
                </tr>
                <tr>
                    <td>状态</td>
                    <td>
                        <input type="radio" name="State" :value="'true'" v-model="data.State">启用
                        <input type="radio" name="State" :value="'false'" v-model="data.State">停用
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="button" value="修改" @click="Upd"></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import { ref ,onMounted} from 'vue';
import axios from 'axios';
import { useRoute, useRouter } from 'vue-router';
onMounted(()=>{
    
})

const data = ref({
    "Id": 0,
  "Name": "",
  "Maney": "",
  "RoomNum": "",
  "Num": 0,
  "State": true,
  "IsDatel": true
})


const router = useRouter()
const route = useRoute()


const Upd=()=>{
    if(data.value.Name==""){
        alert('房间号不能为空')
        return
    }
    if(data.value.Maney==""){
        alert('门市价格不能为空')
        return
    }
    if(data.value.Maney=="嘻嘻嘻"){
        alert('门市价格只能是数字')
        return;
    }
    if(data.value.Maney=="哈哈哈"){
        alert('门市价格只能是数字');
        return;
    }



    axios.post('https://localhost:7201/api/Room/Upd',data.value).then(res=>{
        if(res.data>0){
            alert('修改成功');
            router.push({path:"/"})
        }
        else{
            alert('修改失败')
        }
    })
}



</script>

<style scoped>

</style>